//
//  BuildingTableViewCell.m
//  Kfangchan
//
//  Created by liran on 14/11/7.
//  Copyright (c) 2014年 Beijing Renjuren Network Technology Co., Ltd. All rights reserved.
//

#import "BuildingTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface BuildingTableViewCell()

@property (strong, nonatomic) Building *building;

@property (strong, nonatomic) IBOutlet UIImageView *imgUrlImageView;
@property (strong, nonatomic) IBOutlet UIImageView *tagImgUrlImageView;
@property (strong, nonatomic) IBOutlet UIImageView *activeImageView;
@property (strong, nonatomic) IBOutlet UILabel *activeLabel;
@property (strong, nonatomic) IBOutlet UILabel *nameLabel;
@property (strong, nonatomic) IBOutlet UILabel *avgPriceLabel;
@property (strong, nonatomic) IBOutlet UILabel *maxCommissionLabel;
@property (strong, nonatomic) IBOutlet UILabel *payCommissionLabel;
@property (strong, nonatomic) IBOutlet UILabel *customerDefinitionLabel;

@end

@implementation BuildingTableViewCell

- (void)awakeFromNib {
//    self.contentView.layer.shadowColor = [UIColor blackColor].CGColor;
//    self.contentView.layer.shadowOffset = CGSizeMake(0, 1);
//    self.contentView.layer.shadowOpacity = 0.1;
//    self.contentView.layer.shadowRadius = 1;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark -
#pragma mark 封装cell
- (void)initCell:(Building *)entity {
    self.building = entity;
    
    [self.imgUrlImageView sd_setImageWithURL:[NSURL URLWithString:self.building.imgUrl] placeholderImage:[UIImage imageNamed:@"building_default.png"]];
    if (self.building.tagImgUrl) {
        [self.tagImgUrlImageView sd_setImageWithURL:[NSURL URLWithString:self.building.tagImgUrl]];
    }
    if (self.building.stickActiveId > 0) {
        self.activeImageView.image = [UIImage imageNamed:@"building_active.png"];
        self.activeLabel.text = self.building.stickActive.name;
    } else {
        self.activeImageView.image = nil;
        self.activeLabel.text = @"";
    }
    self.nameLabel.text = [NSString stringWithFormat:@"【%@】%@", self.building.area, self.building.name];
    self.avgPriceLabel.text = [NSString stringWithFormat:@"均价：%@", self.building.avgPrice];
    self.maxCommissionLabel.text = [NSString stringWithFormat:@"%@", self.building.maxCommission];
    self.payCommissionLabel.text = self.building.payCommission;
    self.customerDefinitionLabel.text = self.building.customerDefinition;
    
    
}

- (IBAction)recommendCustomer:(id)sender {
    if (self.handle) {
        self.handle(@(self.building.pkid));
    }
}

@end
